<template>
  <div>
    <router-link to="/" v-if="data.length>0">
    <div class="top" >
      <div class="left" >
        <img :src="data[0].goodsPic" alt>
      </div>
      <div class="right">
        <p class="title">{{data[0].goodsName}}</p>
        <p>参考价:{{data[0].reference_price}}</p>
        <p>{{data[0].books}}</p>
        <p>
          {{data[0].goodsDetails.split(",")[0]}}
          <br>
          {{data[0].goodsDetails.split(",")[1]}}
          <br>
          {{data[0].goodsDetails.split(",")[2]}}
        </p>
      </div>
    </div>
    </router-link>
    <h2>购买推荐</h2>
    <router-link to="/hot" :key="index"
          v-for="(item,index) in data[0].buyAddress"
          v-if="data[0].buyAddress.length>0">
      <div class="container">
        <ul>
          <li>
            <div class="ileft">
              <img class="img" :src="item.goodsPic">
            </div>
            <div class="tright">
              <h3>{{item.address}}</h3>
              <p class="txt">价格:&nbsp;&nbsp;¥359.00</p>
              <p class="txt">
                <span>
                  市场价:&nbsp;&nbsp;¥
                  <del>540.00</del>
                </span>
                <span class="ping">
                  <img src="../assets/icon/mine/pinglun.png" alt>
                  {{item.commentNum}}人评价
                </span>
              </p>
            </div>
          </li>
        </ul>
      </div>
    </router-link>
     <div class="f">
      <ul>
        <router-link to="/details" exact>
          <li class="ff">
            口碑点评
            <span>|</span>
          </li>
        </router-link>
        <router-link to="/hot">
          <li class="ff">
            相关话题
            <span>|</span>
          </li>
        </router-link>
        <router-link to="/hot">
          <li class="ff">相似产品</li>
        </router-link>
      </ul>
    </div>
    <router-link to="/hot">
      <div class="container">
        <div class="star">
          <p>4.0</p>
          <p>
            <img src="../assets/icon/mine/red.png" alt>
            <img src="../assets/icon/mine/red.png" alt>
            <img src="../assets/icon/mine/red.png" alt>
            <img src="../assets/icon/mine/red.png" alt>
            <img src="../assets/icon/mine/gray.png" alt>
          </p>
        </div>
        <div class="jd">
          <div class="pl">
            <span class="xing">五星</span>
            <p class="tiao">
              <span></span>
            </p>
            <span class="jin">80%</span>
          </div>
          <div class="pl">
            <span class="xing">四星</span>
            <p class="tiao">
              <span></span>
            </p>
            <span class="jin">80%</span>
          </div>
          <div class="pl">
            <span class="xing">三星</span>
            <p class="tiao">
              <span class="span3"></span>
            </p>
            <span class="jin">40%</span>
          </div>
          <div class="pl">
            <span class="xing">二星</span>
            <p class="tiao">
              <span class="span2"></span>
            </p>
            <span class="jin">14%</span>
          </div>
          <div class="pl">
            <span class="xing">一星</span>
            <p class="tiao">
              <span class="span1"></span>
            </p>
            <span class="jin">7%</span>
          </div>
        </div>

        <div class="uinfo" :key="index"
          v-for="(item,index) in data[0].commentInfo"
          v-if="data[0].commentInfo.length>0">
          <p class="userinfo">
            <img :src="item.headPic" alt><span class="t">{{item.userName}}</span>
          </p>
          <img class="pic" :src="item.headPic" alt>
          <p class="text">{{item.commentText}}</p>
        </div>
      </div>
    </router-link>
  </div>
</template>

<script>
export default {
  name: "DetailsInfo",
  data() {
    return {
      data: []
    };
  },
  mounted() {
    if (this.$route.params.goodsid) {
      this.$axios
        .get("http://localhost:3000/api/chanpinInfo", {
          params: {
            goodsId: this.$route.params.goodsid
          }
        })
        .then(res => {
          console.log(res.data);
          this.data = res.data;
        })
        .catch(error => {
          console.log(error);
        });
    }
  }
};
</script>

<style lang="less" scoped>
.active {
  color: #ff406f;
}
.top {
  margin-top: 100px;
  width: 351px;
  margin: 100px 12px 12px;
}
.left {
  width: 120px;
  height: 120px;
  float: left;
  margin-right: 21px;
  border: 1px solid #ccc;
  border-radius: 5px;
  text-align: center;
  box-sizing: border-box;
}
.left img {
  width: 110px;
  height: 110px;
  margin-top: 3px;
}
.title {
  font-size: 14px;
  color: #382b2b;
}
.right {
  width: 210px;
  float: left;
  font-size: 13px;
  color: #808080;
}
h2 {
  width: 100%;
  height: 50px;
  line-height: 50px;
  padding: 0 12px;
  color: #808080;
}
.container {
  margin-left: 10px;
  width: 355px;
  padding: 20px 10.5px;
  border: 2px solid #e7e7e7;
  box-shadow: 0px 0px 10px 5px #e7e7e7;
  border-radius: 8px;
  box-sizing: border-box;
  margin-bottom: 10px;
}
.ileft {
  float: left;
  width: 90px;
  height: 90px;
  text-align: center;
  border: 1px solid #ccc;
  border-radius: 5px;
  box-sizing: border-box;
  margin-right: 15px;
}
.img {
  margin-top: 5px;
  width: 80px;
  height: 80px;
}
li {
  display: inline-block;
  height: 90px;
  margin-bottom: 20px;
}
li:last-child {
  margin-bottom: 0;
}
.tright {
  float: left;
  width: 225px;
  height: 90px;
}
h3 {
  font-size: 18px;
  font-weight: 400;
  color: #808080;
  line-height: 40px;
}
.txt {
  color: #ccc;
  font-size: 14px;
  line-height: 25px;
}
.ping {
  float: right;
}
.ping img {
  width: 15px;
}
.f {
  width: 335px;
  height: 40px;
  margin: 0 10px;
  text-align: center;
}
.f ul {
  // height: 20px;
  // margin: 0 0 20px 0;
  margin-left: 24px;
}
.ff {
  display: inline-block;
  // float: left;
  width: 100px;
  height: 40px;
  margin-bottom: 0;
  text-align: center;
  font-size: 18px;
  line-height: 40px;
  // border-right: 2px solid #ccc;
  // padding: 8px 0;
}
.f ul span {
  display: inline-block;
  height: 40px;
  line-height: 40px;
  float: right;
}
.container .star {
  width: 45%;
  height: 120px;
  float: left;
  text-align: center;
  line-height: 20px;
}
.star img {
  width: 15px;
}
.star p:first-child {
  margin-top: 40px;
}
.container .jd {
  width: 55%;
  float: left;
  height: 120px;
  margin-top: 10px;
}
.pl {
  width: 100%;
  height: 20px;
  line-height: 20px;
  margin-bottom: 5px;
}
.xing,
.jin {
  float: left;
  width: 30px;
  font-size: 12px;
}
.jin {
  float: right;
}

.tiao {
  width: 117.5px;
  height: 10px;
  border: 1px solid #ccc;
  border-radius: 50px;
  box-sizing: border-box;
  float: left;
  margin-top: 5px;
  position: relative;
}
.tiao span {
  display: inline-block;
  position: absolute;
  width: 80%;
  height: 6px;
  background-color: #ff406f;
  border: 1px solid #ff406f;
  border-radius: 50px;
  top: 0px;
}
.tiao .span3 {
  width: 40%;
}
.tiao .span2 {
  width: 14%;
}
.tiao .span1 {
  width: 7%;
}
.uinfo {
  margin-top: 150px;
  width: 355px;
  margin: 0 10px;
  .userinfo {
    width: 100%;
    text-align: left;
    img {
      width: 18px;
      margin-right: 10px;
    }
    margin: 10px 0 5px;
  }
  .t{
    font-size: 15px;
  }
  .pic {
    float: left;
    width: 75px;
    margin-right: 15px;
  }
  p {
    width: 230px;
    font-size: 12px;
    color: #ccc;
    line-height: 20px;
  }
}
</style>


